<template>
    <div class="container">
        <h3>检疫管理</h3>
        <el-row style="margin-top:20px;">
            <el-col :span="7">
                <el-input placeholder="品种名称/养殖批号" v-model="searchName" style="width:300px;">
                    <i slot="prefix" class="el-input__icon el-icon-search"></i>
                    <el-button slot="append" @click="handleSearch">搜索</el-button>
                </el-input>
            </el-col>
        </el-row>
        <el-table
            :data="tableData"
            border
            style="margin-top:20px;"
            ref="multipleTable"
            header-cell-class-name="table-header">
            <el-table-column prop="seedName" sortable label="品种名称"></el-table-column>
            <el-table-column prop="batch" sortable label="养殖批号"></el-table-column>
            <el-table-column prop="breedNumber" sortable label="数量"></el-table-column>
            <el-table-column prop="isQuarantine" sortable label="状态">
            <template slot-scope="scope">
                 {{scope.row.isQuarantine == 0?'未检疫':'已检疫'}}
            </template>
            </el-table-column>
            <el-table-column label="操作" width="150" align="center">
                <template slot-scope="scope">
                    <el-button type="text" v-show="!check" v-if="scope.row.isQuarantine != 0"  @click="handleCheck(scope.$index, scope.row)">查看</el-button>
					<el-button type="text" v-show="!quarantine" v-if="scope.row.isQuarantine != 1" @click="handlequarantine(scope.$index, scope.row)">检疫</el-button>
                </template>
            </el-table-column>
        </el-table>
        <el-pagination
            layout="total, prev, pager, next, jumper"
            :page-size="pagesize"
            :current-page.sync="currentPage"
            :total="total"
            @current-change="handleCurrentChange"
            style="margin-top:20px"
        ></el-pagination>
    </div>
</template>
<script>
import { breed_findByList } from '@/request/breedApi';
export default {
    data() {
        return {
			labelPosition:'right',
			dialogFormVisible:false,
			ruleForm:{},
            total: 0,
            currentPage: 1,
            pagesize: 10,
            searchName: '',
            tableData: [],
            form: {},
            check:true,
            quarantine:true,
        };
    },
    mounted() {
        this.init();
        this.judgmentAuthority()
    },
    methods: {
		// 报损点击确定
		submitForm(){
			this.dialogFormVisible = false
		},
		handlequarantine(index,row){
			this.$router.push({
			    path: '/yzquarantine/anti',
			    query: {
			        id: row.id
			    }
			});
		},


		// 分页
        handleCurrentChange(val) {
            this.currentPage = val;
            this.init();
        },

		
		// 页面一进来加载
        init() {
             var params = {
                 searchName: this.searchName,
                 page: this.currentPage
             };
             breed_findByList(params).then((res) => {
                if (res.code == 200) {
                  this.tableData = res.rows;
                     this.total = res.total;
                }
           });
        },
		// 查看
        handleCheck(index, row) {
            this.$router.push({
                path: '/yzquarantine/check',
                query: {
                    id: row.id
                }
            });
        },
        //搜索
        handleSearch() {
            this.currentPage = 1;
            this.init();
        },

        //判定操作按钮显示
        judgmentAuthority(){
            var type = JSON.parse(localStorage.getItem("userInfo")).appMenus
            type.map(item => {
                if(item.appName == '养殖追溯管理系统'){
                    item.menus.map(item1 => {
                        if(item1.name == '检疫管理' && item1.children != null){
                            for(var i = 0; i < item1.children.length; i++){
                                if(item1.children[i].name == '查看') this.check = false;
                                if(item1.children[i].name == '检疫') this.quarantine = false;
                            }
                        }
                    })
                }
            })
        }
     
    }
};
</script>

<style scoped lang="less">
/deep/.upload-daoru {
    background: #eee;
    .el-upload {
        border: none;
        width: auto;
        height: auto;
        border-radius: 0;
        float: right;
        margin-right: 10px;
    }
}
.el-table {
    margin-top: 20px;
}
.el-pagination {
    text-align: center;
}
.el-pagination {
    text-align: center;
}
.el-col {
    margin-bottom: 0;
}
.avatar-uploader .el-upload {
    border: 1px dashed #d9d9d9;
    border-radius: 6px;
    cursor: pointer;
    position: relative;
    width:180px;
    overflow: hidden;
  }
  
  .avatar-uploader .el-upload:hover {
    border-color: #409EFF;
  }
  .el-upload--text{
      width:180px;
  }
  .avatar-uploader-icon {
    font-size: 28px;
    color: #8c939d;
    width: 178px;
    height: 178px;
    line-height: 178px;
    text-align: center;
  }
  .avatar {
    width: 178px;
    height: 178px;
    display: block;
  }
</style>